package com.aqie.easy.tree;

/**
 * 657. 机器人能否返回原点
 */
public class JudgeCircle {
    public boolean judgeCircle(String moves) {
        int x = 0,y = 0;
        for (Character c : moves.toCharArray()){
            switch (c){
                case 'U':
                    x ++;
                    break;
                case 'D':
                    x--;
                    break;
                case  'L':
                    y++;
                    break;
                case 'R':
                    y--;
                    break;
            }
        }
        return x == 0 && y == 0;
    }
}
